Repository navigation
PostgreSQL: Parse ROUTINE and ALL PROCEDURES | ROUTINES IN SCHEMA grant targets - #2761
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #2761 +/- ##
==========================================
+ Coverage 82.58% 82.59% +0.01%
==========================================
Files 42 42
Lines 35565 35597 +32
Branches 35565 35597 +32
==========================================
+ Hits 29371 29403 +32
Misses 2660 2660
Partials 3534 3534 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
690ce6a to
a9a1160
Compare
| Some(GrantObjects::Procedures( | ||
| self.parse_comma_separated(Parser::parse_function_desc)?, | ||
| )) | ||
| } else if self.parse_keyword(Keyword::ROUTINE) { |
There was a problem hiding this comment.
This breaks a table named routine: GRANT SELECT ON TABLE routine TO r parses, but Tables prints without TABLE, so the output GRANT SELECT ON routine TO r no longer re-parses (Expected: TO, found: r). Guarding on the next token being a word other than TO/FROM before consuming ROUTINE avoids it.
There was a problem hiding this comment.
I think tables named function, procedure and sequence would also break here.
There was a problem hiding this comment.
ROUTINE is now only read as the object type when the next token is not TO, FROM, , or ., which is how PostgreSQL itself tells a table named routine from a routine.
Tables named function, procedure and sequence already failed this way on main, and so did schema, database, view and the other object-type keywords. The same check now guards all of them, so GRANT SELECT ON function TO r and the rest parse as tables and ON TABLE function round-trips.
cb3476e to
88c587b
Compare
|
Thanks @sabir-akhadov-localstack for the review! I will be merging this one now. cc @alamb |
PostgreSQL's
GRANTandREVOKEtakeON ROUTINEwith the same signature list asON FUNCTIONandON PROCEDURE, and cover a whole schema withON ALL PROCEDURES IN SCHEMAandON ALL ROUTINES IN SCHEMA(https://www.postgresql.org/docs/current/sql-grant.html). None of the three parsed.GRANT EXECUTE ON ROUTINE f(int) TO bobfailed withExpected: TO, found: f, andGRANT EXECUTE ON ALL ROUTINES IN SCHEMA s TO bobwithExpected: TO, found: ROUTINES.GrantObjectsgainsRoutines,AllProceduresInSchemaandAllRoutinesInSchema, next to theFunctionsandProceduresvariants from #2727. A routine can be a function or a procedure, so each form keeps its own variant and prints back as written.